1 <?php
2     
3     session_start();
4     require
"admin/includes/functions.php";
5     require
"admin/includes/db.php";
6
7     $name =
"";
8     $desc =
"";
9     $category =
"";
10     $price =
"";
11     $id =
"";
12     
13     
if($_SERVER['REQUEST_METHOD'] == 'GET') {
14         
15         
if(isset($_GET['fid']) && preg_replace("#[^0-9]#", "", $_GET['fid']) != "") {
16             
17             $fid = preg_replace(
"#[^0-9]#", "", $_GET['fid']);
18             
19             
if($fid != "") {
20                 
21                 $get_detail = $db->query(
"SELECT * FROM food WHERE id='".$fid."' LIMIT 1");
22                 
23                 
if($get_detail->num_rows) {
24                     
25                     
while($row = $get_detail->fetch_assoc()) {
26                         
27                         $id = $row[
'id'];
28                         $name = $row[
'food_name'];
29                         $desc = $row[
'food_description'];
30                         $cat = $row[
'food_category'];
31                         $price = $row[
'food_price'];
32                         
33                     }
34                     
35                 }
else{
36                     
37                     header(
"location: index.php");
38                     
39                 }
40                 
41             }
42             
43         }
else{
44             
45             header(
"location: index.php");
46             
47         }
48         
49     }elseif($_SERVER[
'REQUEST_METHOD'] == 'POST') {
50         
51         
if(isset($_POST['submit'])) {
52             
53             $id = preg_replace(
"#[^0-9]#", "", $_POST['fid']);
54             $qty = preg_replace(
"#[^0-9]#", "", $_POST['amount']);
55             
56             header(
"location: basket.php?fid=".$id."&qty=".$qty."");
57             
58         }
59         
60     }
61     
62 ?>
63
64 <!Doctype html>
65
66 <html lang=
"en">
67 <meta charset=
"utf-8" />
68 <meta http-equiv=
"X-UA-Compatible" content="IE=edge,chrome=1" />
69 <meta name=
"viewport" content="width=device-width, initial-scale=1.0" />
70
71 <meta name=
"description" content="" />
72
73 <meta name=
"keywords" content="" />
74
75 <head>
76     
77 <title>Trà sữa khơi nguồn cảm hứng</title>
78
79 <link rel=
"stylesheet" href="css/main.css" />
80
81 <script src=
"js/jquery.min.js" ></script>
82
83 <script src=
"js/myscript.js"></script>
84     
85 </head>
86
87 <body>
88     
89 <?php require
"includes/header.php"; ?>
90
91 <!--<div
class="parallax" onclick="remove_class()">
92     
93     <div
class="parallax_head">
94         
95         <h2>Meal</h2>
96         <h3>Description</h3>
97         
98     </div>
99     
100 </div>--><br/><br/><br/>
101
102 <div
class="content remove_pad" onclick="remove_class()">
103     
104     <div
class="inner_content on_parallax">
105         
106         <h2><span
class="fresh">Mô tả</span></h2>
107         
108         <div
class="parallax_content">
109             
110             <div
class="detail_holder">
111                 
112                 <div
class="detail_img">
113                 
114                     <img src=
"image/FoodPics/<?php echo $id;?>.jpg" width="100%" alt="no image found" />
115                     
116                 </div>
117                 
118                 <div
class="detail_desc">
119                     
120                     <form
class="" method="post" action="detail.php">
121                         
122                         <h3
class="desc_header"><?php echo $name; ?></h3>
123                         <p
class="desc_detail"><?php echo $desc; ?> </p>
124                         <p><span
class="bold_desc">Danh mục:</span> <?php echo $cat; ?></p>
125                         <p><span
class="bold_desc price">Giá:</span> #<span id="price"><?php echo $price; ?></span></p>
126                         <div
class="form_group">
127                             
128                             <p><span
class="bold_desc">Số lượng:</span></p>
129                             <p
class="label_center"><label class="subtract" onclick="subtract_price();">-</label><input readonly type="text" id="amount" name="amount" value="1"><label class="add" onclick="sum_price();">+</label><p>
130                             
131                         </div>
132                         
133                         <p><span
class="bold_desc">Tổng tiền:</span> #<span id="total_price"><?php echo $price; ?></span></p>
134                         
135                         <div
class="form_group">
136                             <input type=
"hidden" name="fid" value="<?php echo $id; ?>">
137                             <input type=
"submit" name="submit" class="submit add_order" value="Đặt món" />
138                             
139                         </div>
140                         
141                     </form>
142                     
143                 </div>
144                 
145                 <p
class="clear"></p>
146                 
147             </div>
148             
149         </div>
150         
151     </div>
152     
153 </div>
154
155 <div
class="content" onclick="remove_class()">
156     
157     <div
class="inner_content">
158         
159         <div
class="contact">
160             
161             <div
class="left">
162                 
163                 <h3>Địa chỉ</h3>
164                 <p>
247 Lê Trọng Thấn - Thanh Xuân</p>
165                 <p>Hà Nội</p>
166                 
167             </div>
168             
169             <div
class="left">
170                 
171                 <h3>Liên hệ</h3>
172                 <p>
0972949801</p>
173                 <p>trasuathomngon@gmail.com</p>
174                 
175             </div>
176             
177             <p
class="left"></p>
178             
179             <div
class="icon_holder">
180                 
181                 <a href=
"#"><img src="image/icons/Facebook.png" alt="image/icons/Facebook.png" /></a>
182                 <a href=
"#"><img src="image/icons/Google+.png" alt="image/icons/Google+.png" /></a>
183                 <a href=
"#"><img src="image/icons/Twitter.png" alt="image/icons/Twitter.png" /></a>
184                 
185             </div>
186             
187         </div>
188         
189     </div>
190     
191 </div>
192
193 <div
class="footer_parallax" onclick="remove_class()">
194     
195     <div
class="on_footer_parallax">
196         
197         <p>&copy; <?php echo strftime(
"%Y", time()); ?> <span></span>.Trà Sữa Hương Vị Thơm - Chuẩn Vị Ngon - Khơi Nguồn Cảm Hứng</p>
198         
199     </div>
200     
201 </div>
202     
203 </body>
204
205 </html>
206
207 <script>
208     
209     function sum_price() {
210         
211         amount = $(
"#amount").val();
212         toInt = parseInt(amount);
213         toInt = toInt +
1;
214         $(
"#amount").val(toInt);
215         price = $(
"#price").html();
216         total_price = price * toInt;
217         $(
"#total_price").html(total_price);
218         
219     }
220     
221     function subtract_price() {
222         
223         amount = $(
"#amount").val();
224         toInt = parseInt(amount);
225         
if(toInt == 1) {
226             
227             toInt =
1;
228             
229         }
else{
230             
231             toInt = toInt -
1;
232             
233         }
234         
235         $(
"#amount").val(toInt);
236         price = $(
"#price").html();
237         total_price = price * toInt;
238         $(
"#total_price").html(total_price);
239         
240     }
241     
242 </script>


Gõ tìm kiếm nhanh...